
# coding=utf-8
import os,time
import psycopg2
from datetime import datetime, date, timedelta
from wddb import dbInfo


def readStockIndexCodes(con):
    ls=[]
    cur=con.cursor()
    cur.execute("select code from stock_index_code")
    rows = cur.fetchall()
    for row in rows:
        ls.append(row[0])
    print("readStockCodes len=%s"%(len(ls)))
    return ls

def readStockCodes(con):
    ls=[]
    cur=con.cursor()
    cur.execute("select code from stock_code")
    rows = cur.fetchall()
    for row in rows:
        ls.append(row[0])
    print("readStockCodes len=%s"%(len(ls)))
    return ls
    
def readFundCodes(con):
    ls=[]
    cur=con.cursor()
    cur.execute("select fund_id from fund_code")
    rows = cur.fetchall()
    for row in rows:
        ls.append(row[0])
    print("readFundCodes len=%s"%(len(ls)))
    return ls

def delPathFiles(path):
    ls = os.listdir(path)
    for i in ls:
        c_path = os.path.join(path, i)
        if os.path.isdir(c_path):
            delPathFiles(c_path)
        else:
            os.remove(c_path)